package org.dromara.visitor.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import org.dromara.common.core.domain.R;
import org.dromara.visitor.domain.dto.BlacklistReq;
import org.dromara.visitor.domain.dto.BlacklistResp;
import org.dromara.visitor.service.BlacklistService;
import org.springframework.web.bind.annotation.*;

/**
 * 黑名单
 */
@RestController
@RequestMapping("/blacklist")
public class BlacklistController {
    @Resource
    private BlacklistService blacklistService;

    /**
     * 移入黑名单
     * @param id
     * @param reason
     * @return
     */
    @GetMapping("/add")
    public R add(@RequestParam("id") Long id,@RequestParam(value = "reason",required = false) String reason){
        blacklistService.add(id,reason);
        return R.ok();
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/delete")
    public R delete(@RequestParam("id") Long id){
        blacklistService.backOrgManage(id);
        return R.ok();
    }

    /**
     * 列表查询
     * @param req
     * @return
     */
    @PostMapping("/queryList")
    public R<Page<BlacklistResp>> listPage(@RequestBody BlacklistReq req){
        Page<BlacklistResp> page = blacklistService.listPage(req);
        return R.ok(page);
    }
}
